﻿using System;

namespace Ji.TimeHelper
{
    public static class TimeStampHelper
    {

        /// <summary> 转换标准时间为时间戳 </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static long GetTimeStamp(this DateTime dt)
        {
            return (dt.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
        }

        /// <summary> 转换标准时间为时间戳，包含毫秒部分，占用三位 </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static long GetTimeStampWithMs(this DateTime dt)
        {
            return long.Parse(dt.GetTimeStamp() + "" + DateTime.Now.Millisecond);
        }

    }
}
